package net.wanho.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import net.wanho.entity.User;
import net.wanho.mapper.UserMapper;
import net.wanho.service.UserService;
import org.springframework.stereotype.Service;

/**
 * Author：汤小洋
 * Date：2023-09-27 9:23
 * Description：<描述>
 */
@Service
// @RequiredArgsConstructor
public class UserSerivceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    // private final UserMapper userMapper;

    @Override
    public User login(User user) {
        // 定义条件构造器，用来封装查询条件
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username", user.getUsername())
                .eq("password", user.getPassword());

        // UserMapper userMapper = getBaseMapper();
        // User u = userMapper.selectOne(wrapper);

        User u = getOne(wrapper);
        return u;
    }

}
